home *** CD-ROM | disk | FTP | other *** search
Wrap
/* File: UpgraderPlugin.h Contains: All common function defintions and structures between the upgrader and the plugins Version: Upgrader 1.1 Copyright: © 1997 by Apple Computer, Inc., all rights reserved. */ #ifndef __UPGRADERPLUGIN__ #define __UPGRADERPLUGIN__ #ifndef REZ #include <AppleEvents.h> #include <Dialogs.h> #endif #if defined(__MWERKS__) // <30> #include <SetUpA4.h> #include <A4Stuff.h> #endif // General Shell error numbers that may be returned to plugins #define kCouldNotFindPluginMsgNum 1000 #define kUnknownPlugInHandlerErr 1001 #define kNoHighLevelEventsErr 1002 #define kCouldNotFindResourceMsgNum 1003 #define kMemoryErrorMsgNum 1004 #define kCantSaveDocumentErr 1005 // PSSaveDoc cannot save the specified DocViewer object. #define kForceRestartWarningMsgNum 1006 #define kAppNotFoundMsgNum 1007 #define kDocNotFoundMsgNum 1008 #define kAppCouldNotBeLaunchUnknownProblemMsgNum 1009 #define kAppCouldNotBeLaunchNoEnoughMemoryMsgNum 1010 #define kAppCouldNotBeLaunchFileOpenMsgNum 1011 #define kRightDiskNameWrongDiskInsertedMsgNum 1012 #define kWrongDiskInsertedMsgNum 1013 #define kFileNotFoundOnServerMsgNum 1014 #define kCantEjectCDDiskMsgNum 1015 // Errors Returned by PSQuitShell #define kUserContinuingAfterRestartAlertMsgNum 1030 // Plugin sequence errors #define kUnknownPluginNameErr 1040 // <16> #define kNextPluginSameAsCurrentErr 1041 // <28> // Global data manager errors #define kUnknownGlobalDataErr 2000 #define kGlobalDataOutOfMemErr 2001 #define kUnsupportedPrefsFormatErr 2010 #define kNoPrefsErr 2011 // Panel manager errors #define kPanelItemNotFoundInListErr 2050 #define kCannotLoadNeededResourceErr 2051 #define kNoDataAvailableForItemErr 2052 #define kInternalErr 2053 #define kNoGlobalPanelErr 2054 #define kItemTypeMismatchErr 2055 #define kCantFindTextRsrcErr 2056 #define kItemNotLocalisedErr 2057 #define kCantChangePanelItemToSpecifiedTypeErr 2058 // Dialog IDs : these are needed by plugins to define there own private 'ners' resources #define kStopOrContinueDLOGID 506 // note, center main #define kQuitOrContinueDLOGID 507 // note, center main #define kNoteOKDLOGID 508 // note, center main #define kRestartOrContinueDLOGID 514 // note, center main #define kInsertDiskDLOGID 515 // disk swap icon, center main #define kStopOKDLOGID 519 // stop, center main #define kSkipOrContinueDLOGID 520 // caution, alert parent #define kStopDLOGID 600 // OK, center main *note kStopOKDLOGID // shows a continue button as well as OK #define kStopAndQuitDLOGID 526 // <27> #ifndef REZ #ifdef __cplusplus extern "C" { #endif /* PSErrorAlert related constants */ #define kEmptyString (ConstStr255Param)"\p" // Constants that are used in PSErrorAlert to define the default button and the selected button #define kOKButtonIndex 1 // Skip or continue #define kContinueNotSkipBtnIndex 1 #define kSkipNotContinueBtnIndex 2 // Continue or Quit #define kQuitButtonIndex 1 #define kContinueNotQuitBtnIndex 2 // Continue or Restart #define kRestartButtonIndex 1 #define kContinueNotRestartBtnIndex 2 // yes or no #define kYesButtonIndex 1 #define kNoButtonIndex 2 // constants to indicate to PSErrorAlert whether to look in the // plugins resource file for the error or in the Shell resource file #define kStandardShellError true // Tells PSErrorAlert to look in Shell for error #define kPluginError false // Tells PSErrorAlert to look in Plugin res fork for error // constants for PSQuitShell #define kDontAllowUserToContinue false #define kAllowUserToContinue true //------------------------------------------------------------------------------------------------------ // G L O B A L D A T A D E F I N I T I O N S <15> //------------------------------------------------------------------------------------------------------ typedef OSType GlobalDataType; typedef Ptr GlobalDataPtr; enum // This is the list of global data types shared between plugin's // NOTE. plugin's can store their own global data as well. { kTargetDiskVolRefNumDataType = 'trgt', // The selected volume vRefNum as set by Target Selectin plugin (SInt16). kForceRestartOnQuitDataType = 'rsrq' // Global data identifier to singal to shell and plugins that a restart is required (Boolean). }; //------------------------------------------------------------------------------------------------------ // P L U G I N D E F I N I T I O N S //------------------------------------------------------------------------------------------------------ #define kEventHandlerID 'ehID' #define kTerminationHandlerID 'thID' typedef OSErr ShellErr; typedef OSType HandlerIDType; typedef SInt16 ResourceID; enum { kUseDefaultNextModuleName = 0 }; //------------------------------------------------------------------------------------------------------ // P A N E L M A N A G E R D E F I N I T I O N S //------------------------------------------------------------------------------------------------------ typedef WindowPtr PanelPtr; #define kGlobalPanel (void *)0xFFFFFFFF // Pass this constant to PSShowPanel/PSHidePanel if the current // global panel is unknown (eg. when the plugin does not itself display // a panel). #define kHelpPanel (void *)0xFFFFFFFE enum // Definitions for the 'inFlags' parameter to PSNewCustomPanel() { kGrowWindow = 0x02, kIsGlobal = 0x04, kHasGoAwayBox = 0x10 // <07> }; typedef UInt8 DVFlags; // Type and definitions for the panel item types typedef unsigned long PanelItemType; typedef PanelItemType DocViewerType; // <31> subset of PanelItemType enum { kStyledTextType = 'STXT', // 'TEXT' and 'styl' pairs kStyledStringType = 'SSTR', // 'STR#', index and 'finf' kPICTType = 'PICT', kDocResType = 'DOCV', // 'TEXT', 'styl' and 'PICT's stored in resources kDocFileType = 'DOCF', // SimpleText file will optional 'styl' and 'PICT' in resource fork. kControlType = 'CNTL', kIconType = 'ICON', kUserItemType = 'USER' // User panel item for drawing custom items. }; enum // <28> Used in PSAlert { kUpgraderFile = 0, kClientDataFile, kCurrentPluginResFile }; typedef short DocumentType; // Used in PSAlert typedef Byte DocLocationType; // kReadFromResourceFile, kReadFromSimpleTextFile // <22> enum { // <07> kPrinterAvailableMask = 0x00000001, kStandardFilePackageAvailableMask = 0x00000002 }; typedef unsigned long EnvironmentType; // <22> enum { // <22> kReadFromResourceFile = true, // <25> kReadFromSimpleTextFile = false }; // Type and bit definitions for the action panel item attribute typedef UInt16 PanelActionType; enum { kContinueButtonMask = 0x0001, kGoBackButtonMask = 0x0002, kQuitButtonMask = 0x0004, kHelpButtonMask = 0x0008, kDefaultButtonMask = 0x0010 }; typedef Handle PanelUserItemHandle; // <31> // Build in 'finf' resource ID's for the fontInfo field of StyledStringDesc. enum { kUpgraderFonts = 128, kLargeTextStyle = 0, // <33> kMediumTextStyle, kSmallTextStyle, kAlertTextStyle // <32> }; enum { // where the 'finf' is to be read from kFontInfoInClientDataFile, kFontInfoInPluginFile, kFontInfoInShell, kFontInfoInAnyFile }; // Constants to use with PSLaunchFile #define kLaunchAppInFront true // Tells PSLaunchFile to bring the launched application to the front #define kLaunchAppInBack false // Tells PSLaunchFile to leave the launched application in the back. struct FontInfoRec { // <21> short font; short style; short size; }; typedef struct FontInfoRec FontInfoRec, *FontInfoRecPtr; /* Macros to customize Metrowerks code resource macros */ // Call this Macro whenever control is swithched to the plugin #if defined(__MWERKS__) // <30> #define EnterPlugin() \ EnterCodeResource(); #endif // Call this Macro whenever control is from the plugin to the shell #if defined(__MWERKS__) // <30> #define ExitPlugin() \ ExitCodeResource() #endif extern QDGlobals *gQDPtr; // <30> /* PROTOTYPES */ // Global Data Manager calls extern ShellErr PSSetGlobalData( GlobalDataType inGlobalDataType, GlobalDataPtr inGlobalDataPtr, Size inDataSize ); extern ShellErr PSGetGlobalData( GlobalDataType inGlobalDataType, GlobalDataPtr inGlobalDataPtr, Size inMaxDataSize, Size *outActualDataSize ); // Plugin management calls extern ShellErr PSGoToPreviousPlugin( void ); extern ShellErr PSGoToNextPlugin( ResourceID inStrResID ); extern ShellErr PSQuitShell( Boolean canAllowUserToContinue ); // <03> extern ShellErr PSRegisterHandler( HandlerIDType inHandlerType, UniversalProcPtr inHandlerProcPtr ); // Panel management calls extern ShellErr PSSetupNewPanel( SInt16 inPanelItemsRsrcID, PanelPtr *outPanelPanelPtr ); extern ShellErr PSNewCustomPanel( short inPanelItemsRsrcID, DVFlags inFlags, PanelPtr *outPanelPanelPtr ); extern ShellErr PSUpdatePanel( PanelPtr inPanel ); extern void PSDisposePanel( PanelPtr inThePanel ); extern ShellErr PSShowPanel(PanelPtr inPanel ); extern void PSHidePanel( PanelPtr inPanel ); extern Boolean PSGetPanelItemHit( PanelPtr inPanel, EventRecord *inPanelEvent, short *outItemHit); extern ShellErr PSSetPanelItem(PanelPtr inPanel, short inItemNumber, PanelItemType inItemType, Handle inItemHandle, Rect *inItemRect); extern ShellErr PSGetPanelItem(PanelPtr inPanel, short inItemNumber, PanelItemType *outItemType, Handle *outItemHandle, Rect *outItemRect); extern void PSSetPRefCon(PanelPtr inPanel, long inRefCon); extern long PSGetPRefCon(PanelPtr inPanel); extern ShellErr PSSetPanelItemAction(PanelPtr panel, short itemNumber, PanelActionType actionType); extern TEHandle PSNewStyledStringItem(Rect *inItemRect, short inSTRListRsrcID, short inStringListItem, short inFontNum, short inFontStyle, short inFontSize); extern TEHandle PSNewStyledTextItem(Rect *inItemRect, short inTEXTRsrcID); extern PanelUserItemHandle PSNewUserItem(UserItemProcPtr inUserItem, Boolean transparent); extern Handle PSNewDocViewerItem(PanelPtr inPanel, Rect *inItemRect, DocViewerType inDocViewerType, short inTextRsrcID, short inBasePICTRsrcID); extern ShellErr PSActivatePanel(PanelPtr inPanel, Boolean shouldActivate); // DocViewer item related calls extern ShellErr PSHandleDocScroll(PanelPtr inPanel, Point localPt, short inDocItem); extern void PSSaveDoc( PanelPtr inPanel, short inDocItem) ; extern ShellErr PSPrintDoc( PanelPtr inPanel, short inDocItem ); // Standard help windows calls extern OSErr PSSetupHelpWindow ( DocLocationType location, short resID, short basePICTResID, Str255 helpPanelTitleStr, PanelPtr *outHelpPanel ); // <28> extern void PSDisplayHelpWindow ( PanelPtr inHelpPanel ); // <28> extern void PSCloseHelpWindow ( PanelPtr helpPanel ); // <22> extern Boolean PSHandleHelpWindowEvent ( PanelPtr inHelpPanel, EventRecord *inEvent ); // <22> // Utility calls extern OSErr PSCheckEnvironment ( EnvironmentType *theEnvironment ); // <22> extern Boolean PSReadFontInfo ( short location, short inResID, short inFontItem, short *outFontFace, short *outFontStyle, short *outFontSize ); // <21> // <29> extern Boolean PSLaunchFile(SInt16 inAppFileRefRsrcID, SInt16 inDocFileRefRsrcID, AEDescList *inOptionalOpenParams, Boolean inLaunchAppInFront, ProcessSerialNumber *outApplicationPSN); extern SInt16 PSErrorAlert( SInt16 errNum, Boolean isStandardShellErr, ConstStr255Param p0, ConstStr255Param p1, ConstStr255Param p2, ConstStr255Param p3, SInt16 inDefaultButton, SInt16 inCancelButton ); extern void PSCollect(SInt16 inResListRsrcID); // <19> extern SInt16 PSAlert(short DLOGID, DocumentType whichFileContainsDLOG, ConstStr255Param alertText, ConstStr255Param p0, ConstStr255Param p1, ConstStr255Param p2, ConstStr255Param p3, SInt16 inDefaultButton, SInt16 inCancelButton ); /* Prototypes for the 3 required plug-in handler routines */ void InitializePluginModule ( void* inPSTable, SInt32 inRefCon, Boolean inEnterAtBeginning ); Boolean HandleEventForPluginModule ( EventRecord *inEvent ); void TerminatePluginModule ( void ); /* Macro so plugin main entry point conforms to ERS */ #define InitializePluginModule main // <30> void SetupPlugin( void *shellFunctions ); #ifdef __cplusplus } #endif #endif //REZ #endif